import requests

class FileManager:
    def __init__(self, base_url):
        self.base_url = base_url

    def exists(self, filename: str) -> bool:
        response = requests.get(f"{self.base_url}/exists/{filename}")
        return response.json().get("exists", False)

    def delete(self, filename: str):
        response = requests.delete(f"{self.base_url}/delete/{filename}")

        if response.status_code == 200:
            print(response.json()["message"])
        else:
            raise FileNotFoundError("File not found")

# 示例用法
if __name__ == "__main__":
    manager = FileManager(base_url="http://127.0.0.1:8000")

    # 检查文件是否存在
    if manager.exists("file.txt"):
        print("File exists.")
        # 删除文件
        manager.delete("file.txt")
    else:
        print("File does not exist.")
